select
	d.MaterialId
	,e.VendorId

	,f.Code
	,f.Name
	,e.Price
	,e.ProcurementCycle
	,e.PreProcurementCycle
	,a.BatchAmount
	,d.SingleCosts
	,e.MaterialId
	,a.BatchAmount*d.SingleCosts Quantity
	,DATEADD(DAY,e.PreProcurementCycle+e.ProcurementCycle,GETDATE())
from ProduceConduct a
inner join Product b on b.ProductId=a.ProductId
inner join BOM c on c.Code=b.Code
inner join BOMDetails d on d.BOMId=c.BOMId
left join Quotation e on e.MaterialId=d.MaterialId
left join Vendor f on f.VendorId=e.VendorId
order by f.Code

select * from Quotation
